<include file="Public/min-header"/>
<link href="__PUBLIC__/plugins/daterangepicker/daterangepicker-bs3.css" rel="stylesheet" type="text/css" />
<script src="__PUBLIC__/plugins/daterangepicker/moment.min.js" type="text/javascript"></script>
<script src="__PUBLIC__/plugins/daterangepicker/daterangepicker.js" type="text/javascript"></script>
<div class="wrapper">
  <include file="Public/breadcrumb"/>
  <section class="content">
    <div class="container-fluid">
      <div class="panel panel-default">
        <div class="panel-heading">
          <h3 class="panel-title"><i class="fa fa-list"></i>结算记录</h3>
        </div>
        <div class="panel-body">    
		<div class="navbar navbar-default">                    
                <form id="search-form2" class="navbar-form form-inline"  method="get" action="{:U('store_withdrawals')}">
                <div class="form-group">
<!--                  <label for="input-order-id" class="control-label">状态:</label>
                <div class="form-group">
                  <select class="form-control" id="status" name="status">                       
                    <option value="">全部</option>                    
                    <option value="0"<if condition="$_REQUEST['status'] heq '0'">selected</if>>申请中</option>
                    <option value="1"<if condition="$_REQUEST['status'] eq 1">selected</if>>申请成功</option>
                    <option value="2"<if condition="$_REQUEST['status'] eq 2">selected</if>>申请失败</option>
                  </select>
                </div> -->
                  <div class="input-group">
                    <input type="text" class="form-control" id="store_name" placeholder="商家名" value="{$Think.request.store_name}" name="store_name" />
                  </div>
                              
                  <div class="input-group">
                    <input type="text" class="form-control" id="account_bank" placeholder="收款账号" value="{$Think.request.account_bank}" name="account_bank" />                    
                  </div>
                                
                  <div class="input-group">
                    <input type="text" class="form-control" id="account_name" placeholder="收款账户名" value="{$Think.request.account_name}" name="account_name" />                    
                  </div>
                  
                   <div class="input-group margin">                    
                    <div class="input-group-addon">
                        结算时间<i class="fa fa-calendar"></i>
                    </div>
                       <input type="text" id="start_time" value="{$create_time}" name="create_time" class="form-control pull-right" style="width:250px;">
                  </div>                  
                </div>
                <div class="form-group">    
                    <button class="btn btn-primary" id="button-filter search-order" type="submit"><i class="fa fa-search"></i> 筛选</button>    
                </div>

                    <div class="form-group" style="float: right;">
                        <button type="button" class="btn btn-default pull-right" id="daochu"><i class="fa fa-file-excel-o"></i>&nbsp;导出excel</button>
                    </div>
                </form>    
          </div>
                        
          <div id="ajax_return"> 
                 
                    <div class="table-responsive">
                        <table class="table table-bordered table-hover">
                            <thead>
                            <tr>
                                <th class="sorting text-left">店铺id</th>
                                <th class="sorting text-left">店铺名称</th>
                                <th class="sorting text-left">结算时间</th>                                   
                                <th class="sorting text-left">结算金额</th>
								<th class="sorting text-left">退货金额</th>
								<th class="sorting text-left">其他费用</th>
								<th class="sorting text-left">手续费</th>
								<th class="sorting text-left">应付金额</th>
								<th class="sorting text-left">应补金额</th>
                                <th class="sorting text-left">银行名称</th>
                                <th class="sorting text-left">银行账号</th>
                                <th class="sorting text-left">开户名</th>
								<th class="sorting text-left">备注</th>
                                <th class="sorting text-left">通联分账状态</th>
                                <th class="sorting text-left">操作</th>
                            </tr>
                            </thead>
                            <tbody>
                            <volist name="list" id="v">
                                <tr>
                                    <td class="text-left">
                                            {$v.store_id}
                                    </td>
                                    <td class="text-left">
                                        {$v.store_name}
                                        <!--<a href="{:U('Store/store_info',array('store_id'=>$v[store_id]))}">-->
                                             
                                        <!--</a>-->
                                    </td>                                    
                                    <td class="text-left">{$v.create_time|date="Y-m-d",###}</td>                                    
                                    <td class="text-left" style="color: red;">{$v.money}<a href="javascript:" id="chakan" rev="order_statis_shouhuo" style="float: right;" rel="{$v.id}" alt="{$v.store_id}" class="fa fa-eye">明细</a></td>
									<td class="text-left" style="color: green;">-{$v.th_money}<a href="javascript:" id="chakan" rev="order_statis_tuihuo" style="float: right;" rel="{$v.id}" alt="{$v.store_id}" class="fa fa-eye">明细</a></td>
									<td class="text-left" style="color: red;">
                                        <input type="text" onchange="updateSort('{$v.id}',this)" size="4"  value="{$v.expenses}" class="input-sm">
                                    </td>
									<td class="text-left" style="color: blue;">{$v.sxf_money}</td>
									<td class="text-left" style="color: red;">{:round($v['yf_money'],2)}</td>
									<td class="text-left" style="color: #bd1313;">{$v.repair_money}</td>
                                    <td class="text-left">{$v.bank_name}</td>
                                    <td class="text-left">{$v.account_bank}</td>
                                    <td class="text-left">{$v.account_name}</td>
                                    <td class="text-left">{$v.remark}</td>
                                    <td class="text-left">
                                        <if condition="$v['draw_comm'] eq 0">
                                            <span style="color:#0000ff;">未分账</span>
                                            <elseif condition="$v['draw_comm'] eq 1 "/>
                                            <span style="color: green">分账成功</span>
                                        </if>
                                    </td>
                                    <td class="text-left">
                                        <a href="{:U('editStoreWithdrawals',array('id'=>$v['id'],'p'=>$_GET[p]))}" data-toggle="tooltip" title="" class="btn btn-primary" data-original-title="编辑"><i class="fa fa-pencil"></i></a>                                        
                                        
                                        <!-- <a href="javascript:void(0);" onclick="del('{$v[id]}')" id="button-delete6" data-toggle="tooltip" title="" class="btn btn-danger" data-original-title="删除"><i class="fa fa-trash-o"></i></a> -->
                                        
                                    </td>
                                </tr>
                            </volist>
							<tr>
								<td colspan="3" align="right"><b>合计：</b></td>
								<td style="font-size: 15px;color: red;text-align: center;">{$heji}</td>
								<td style="font-size: 15px;color: green;text-align: center;">{$hejituihuo}</td>
								<td style="font-size: 15px;color: blue;text-align: center;">{$hejisxf}</td>
								<td style="font-size: 15px;color: red;text-align: center;">{$hejiprice}</td>
							</tr>
                            </tbody>
                        </table>
                    </div>
                
                <div class="row">
                    <div class="col-sm-6 text-left"></div>
                    <div class="col-sm-6 text-right">{$show}</div>
                </div>
          
          </div>
        </div>
      </div>
    </div>
    <!-- /.row --> 
  </section>
  <!-- /.content --> 
</div>
<!-- /.content-wrapper --> 
 <script>
 // 删除操作
function del(id)
{
	if(!confirm('确定要删除吗?'))
		return false;		
		$.ajax({
			url:"/index.php?m=Admin&c=Finance&a=delStoreWithdrawals&id="+id,
			success: function(v){	
                            var v =  eval('('+v+')');                                 
                            if(v.hasOwnProperty('status') && (v.status == 1))
                               location.href='{:U('Admin/Finance/store_withdrawals')}';
                            else                                
			        layer.msg(v.msg, {icon: 2,time: 1000}); //alert(v.msg);
			}
		}); 
	 return false;
}
  // shadow code修改指定表的排序字段
 function updateSort(id_value,obj)
 {
     var value = $(obj).val();
     $.ajax({
         url:'/index.php?m=Admin&c=Index&a=changeTableValss&id_value='+id_value+'&value='+value,
         success: function(data){
             layer.msg('更新成功', {icon: 1});
             location.reload()
         }
     });
 }
 
$(document).ready(function() {
	$('#start_time').daterangepicker({
		format:"YYYY-MM-DD HH:mm",
		singleDatePicker: false,
		showDropdowns: true,
		minDate:'2021-01-01 00:00',
		maxDate:'2030-01-01 00:00',
		startDate:'{:date("Y-m-d")} 00:00',
		showWeekNumbers: true,
		timePicker: true,
		timePickerIncrement: 1,
		timePicker12Hour: false,
		ranges: {
		   '今天': [moment(), moment()],
		   '昨天': [moment().subtract('days', 1), moment().subtract('days', 1)],
		   '最近7天': [moment().subtract('days', 6), moment()],
		   '最近30天': [moment().subtract('days', 29), moment()],
		   '上一个月': [moment().subtract('month', 1).startOf('month'), moment().subtract('month', 1).endOf('month')]
		},
		opens: 'left',
		buttonClasses: ['btn btn-default'],
		applyClass: 'btn-small btn-primary',
		cancelClass: 'btn-small',
		locale : {
		    applyLabel : '确定',
		    cancelLabel : '取消',
		    fromLabel : '起始时间',
		    toLabel : '结束时间',
		    customRangeLabel : '自定义',
		    daysOfWeek : [ '日', '一', '二', '三', '四', '五', '六' ],
		    monthNames : [ '一月', '二月', '三月', '四月', '五月', '六月','七月', '八月', '九月', '十月', '十一月', '十二月' ],
		    firstDay : 1
		}
	});
$(".table-responsive #chakan").click(function(){
		var myrel=$(this).attr('rel');
		var mytype=$(this).attr('rev');
		var store_id=$(this).attr('alt');
		var myrul='/index.php/admin/Finance/'+mytype+'/id/'+myrel+'/store_id/'+store_id;//+myrel;
			layer.open({
			  type: 2,
			  title:'结算明细',
			  shadeClose: true, //点击遮罩关闭
			  skin: 'layui-layer-rim', //加上边框
			  area: ['920px', '620px'], //宽高
			  content: myrul
		})
    });

    $("#daochu").click(function(){
        //alert('敬请期待。。。');return false;
        var start_time=$("#start_time").val();
        var store_name=$("#store_name").val();
        var account_bank=$("#account_bank").val();
        var account_name=$("#account_name").val();
        location.href="/index.php/admin/Finance/export_withdrawals?create_time="+start_time+'&store_name='+store_name+'&account_bank='+account_bank+'&account_name='+account_name;
    })
});
</script>
</body>
</html>